package com.zhouz.admin.app.gennercode.inter; /*
 * Copyright (C), 2017-2019 广东快洁帮家政服务有限公司
 * FileName: GennerUserServiceAdminImpl.java
 * Author:   张鹏
 * Date:     2019/5/9 20:24
 * History:
 * <author>          <time>          <version>          <desc>
 * 张鹏             2019/5/920:24     V1.00             新建
 * -----------------------------------------------------------
 * 作者姓名           修改时间           版本号            描述
 */


import com.alibaba.druid.pool.DruidDataSource;
import com.xuanner.seq.DbSeqBuilder;
import com.xuanner.seq.sequence.Sequence;
import com.zhouz.admin.app.gennercode.GennerCodeTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;

public abstract class GenerateAbstract {
    @Autowired
    DruidDataSource dataSource;
    Sequence sequence;

    /**
     * id生成器
     * @return
     */
    public Sequence sequence() {
        if(sequence == null){
            this.sequence = DbSeqBuilder.create().dataSource(dataSource).step(this.codeType().step()).stepStart(1).bizName(this.codeType().dbBizName()).build();
        }
        return this.sequence;
    }
    /**
     * 编码类型
     * @return
     */
     public abstract GennerCodeTypeEnum codeType();
}
